<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.6 of March 3, 2008 on April 7, 2009 at 3:52:54 pm</time-stamp>


<class>
<name>SupplierNewLotDialog</name>
<environment>SupplyChain</environment>
<super>UI.SimpleDialog</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>lotNum price itemList model inventory </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>SupplyChain.SupplierNewLotDialog class</class-id> <category>interface specs</category>

<body package="SupplyChain" selector="windowSpec">windowSpec
	"Tools.UIPainter new openOnClass: self andSelector: #windowSpec"

	&lt;resource: #canvas&gt;
	^#(#{UI.FullSpec} 
		#window: 
		#(#{UI.WindowSpec} 
			#label: 'Create New Lot' 
			#bounds: #(#{Graphics.Rectangle} 640 512 1061 808 ) ) 
		#component: 
		#(#{UI.SpecCollection} 
			#collection: #(
				#(#{UI.SequenceViewSpec} 
					#layout: #(#{Graphics.Rectangle} 27 55 167 246 ) 
					#name: #itemList 
					#model: #itemList 
					#useModifierKeys: true 
					#selectionType: #highlight ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 27 29 ) 
					#name: #itemsList 
					#label: 'Items List' ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 255 158 336 181 ) 
					#name: #addToLot 
					#model: #addToLotClick 
					#label: 'Add To Lot' 
					#defaultable: true ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 183 69 ) 
					#name: #lotNumber 
					#label: 'Lot Number' ) 
				#(#{UI.SpinButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 246 68 377 91 ) 
					#name: #lotNum 
					#model: #lotNum 
					#type: #number ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 209 115 ) 
					#name: #price 
					#label: 'Price' ) 
				#(#{UI.SpinButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 246 114 378 136 ) 
					#name: #price 
					#model: #price 
					#type: #number ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 201 208 282 231 ) 
					#name: #done 
					#model: #accept 
					#label: 'Done' 
					#defaultable: true ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 309 208 390 231 ) 
					#name: #cancel 
					#model: #cancel 
					#label: 'Cancel' 
					#defaultable: true ) 
				#(#{UI.LabelSpec} 
					#layout: #(#{Core.Point} 3 273 ) 
					#name: #supplierGUI 
					#label: 'Supplier GUI' ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 257 23 338 46 ) 
					#name: #addItem 
					#model: #addItemClick 
					#label: 'Add Item' 
					#defaultable: true ) ) ) )</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierNewLotDialog class</class-id> <category>instance creation</category>

<body package="SupplyChain" selector="new">new
	^super new initialize</body>
</methods>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<comment>
<class-id>SupplyChain.SupplierNewLotDialog</class-id>
<body>SupplierNewLotDialog holds list of items supplier has, lot number of the item, price of item an an option to add to lot. 

Instance Variables:
	itemList	&lt;SelectionInList&gt;	list of items
	lotNum	&lt;ValueHolder&gt;	lot number of item
	price	&lt;ValueHolder&gt;	price of item

</body>
</comment>

<methods>
<class-id>SupplyChain.SupplierNewLotDialog</class-id> <category>aspects</category>

<body package="SupplyChain" selector="itemList">itemList
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^itemList isNil
		ifTrue:
			[itemList := SelectionInList new]
		ifFalse:
			[itemList]</body>

<body package="SupplyChain" selector="lotNum">lotNum
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^lotNum isNil
		ifTrue:
			[lotNum := 0 asValue]
		ifFalse:
			[lotNum]</body>

<body package="SupplyChain" selector="price">price
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^price isNil
		ifTrue:
			[price := 0 asValue]
		ifFalse:
			[price]</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierNewLotDialog</class-id> <category>accessing</category>

<body package="SupplyChain" selector="inventory">inventory
	
	^inventory</body>

<body package="SupplyChain" selector="inventory:">inventory: aInventory
	
	inventory:= aInventory.
	self changed: #items.
	^self</body>

<body package="SupplyChain" selector="model">model
	
	^model</body>

<body package="SupplyChain" selector="model:">model: aInventory
	
	model:= aInventory.
	self changed: #items.
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierNewLotDialog</class-id> <category>actions</category>

<body package="SupplyChain" selector="addItem">addItem
	"This stub method was generated by UIDefiner"

	^self</body>

<body package="SupplyChain" selector="addItemClick">addItemClick
	"Adds a supplier to the list of suppliers"
	|t1 t2 t3 |

	t2 := Dialog request: 'Item name' initialAnswer: ' '.
	(t2 = '') ifFalse:[
		t3 := Dialog request: 'Item Sku' initialAnswer: ' '.
			(t3= '') ifFalse:[
						t1 := Item new.
						t1 name: t2.
						t1 sku: t3.
						inventory items add: t1.
						inventory changed: #items.].].

	

	^self.</body>

<body package="SupplyChain" selector="addToLot">addToLot

	"This stub method was generated by UIDefiner"

	^self</body>

<body package="SupplyChain" selector="addToLotClick">addToLotClick

	"This stub method was generated by UIDefiner"

	| item	|

	
	itemList selection notNil ifTrue: [	"if there is something selected and the button is clicked....	"
		item:= itemList selection.  	"grab the selected item	"
		item lotNumber: lotNum.			"update the item with the current lot number selection		"
		item sellPrice: price.			" update the item with the current sell price		"
		model items add: item.
	].
	^self.</body>
</methods>

<methods>
<class-id>SupplyChain.SupplierNewLotDialog</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	model:= Inventory new.
	inventory:= Inventory new.	"temp inventory"
	
	   "now we set up the list box for inventory.  We set the model of the list box to be a selectable item"
    
    (itemList:= SelectionInList new) listHolder: ((UI.AspectAdaptor subject: (inventory) sendsUpdates: true)forAspect: #items).
	
	^self</body>
</methods>

</st-source>
